/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jiang Jinxi
 * Date: 2024-04-27
 * Time: 14:58
 */
public class Circle2D {
    private double x;
    private double y;
    private double radius;
    private static double pi = 3.14;

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public double getRadius() {
        return radius;
    }
    public Circle2D(){
        this.x = 0.0;
        this.y = 0.0;
        radius = 1;
    }

    public Circle2D(double x, double y, double radius) {
        this.x = x;
        this.y = y;
        this.radius = radius;
    }
    public double getArea(){

        return pi*radius*radius;
    }
    public double getPerimeter(){
        return pi*radius*2;
    }
    public boolean contains(double x,double y){
        return Math.sqrt((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y)) < radius;
    }
    public boolean contains(Circle2D circle){
        return this.radius-Math.sqrt((this.x-circle.x)*(this.x-circle.x)+(this.y-circle.y)*(this.y-circle.y)) > circle.radius;
    }
    public boolean overlaps(Circle2D circle){
        if(Math.sqrt((this.x-circle.x)*(this.x-circle.x)+(this.y-circle.y)*(this.y-circle.y)) > radius &&
                Math.sqrt((this.x-circle.x)*(this.x-circle.x)+(this.y-circle.y)*(this.y-circle.y)) < this.radius+circle.radius){
            return true;
        }else if(this.radius - Math.sqrt((this.x-circle.x)*(this.x-circle.x)+(this.y-circle.y)*(this.y-circle.y)) < circle.radius){
            return true;
        }
        return false;
    }



}
